package main.threading;

import main.listeners.ListenerContainer;

public class ThreadPoolContainer implements Runnable {
	
	private ListenerContainer controllers;
	private int start, end;
	private Float time;
	
	public ThreadPoolContainer(ListenerContainer controllers, int start, int end) {
		this.controllers = controllers;
		this.start = start;
		this.end = end;
	}
	
	public void setTime(Float time) {
		this.time = time;
	}
	
	@Override
	public void run() {
		assert(time != null);
		try {
			for(int i = start; i < end && i < controllers.size(); i++) {
				((ThreadPoolController)controllers.get(i)).update(time);
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}